Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move azurite scaffolding #5448

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft

Move azurite scaffolding #5448

wants to merge 4 commits into from

Conversation

justindbaur
Copy link
Member

@justindbaur justindbaur commented Feb 26, 2025

🎟️ Tracking

📔 Objective

I had A DAY with my development setup, most of the issue are unrelated to this PR but the last issue I had was an issue scaffolding Azurite. The issue was the current version of the powershell Az module doesn't play nicely with the azurite:latest. To fix this I think a good course of action is lower the amount of versions in play from 3 to 2 and instead rely on the already referenced Azure.* packages. The versions of our packages don't always play nice with azurite either for example having to revert these upgrades: #5447.

So instead of the developer having to manually run setup_azurite.ps1 during the setup process, it will happen automatically on the first start of Api. Any issues with the setup will stop the startup of Api and log the errors it had. This does run on every startup but doesn't clobber anything on subsequent runs.

I have a few open questions that I made comments on the PR and welcome feedback on the approach. If we want to go with this approach and accompanying contributing-docs PR will be made.

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

Copy link
Contributor

github-actions bot commented Feb 26, 2025

Logo
Checkmarx One – Scan Summary & Details0282499c-6909-4e7a-87ae-f7b3e648d65c

Fixed Issues (26)

Great job! The following issues were fixed in this Pull Request

Severity Issue Source File / Package
LOW Log_Forging /src/Billing/Controllers/StripeController.cs: 164
LOW Log_Forging /src/Billing/Controllers/RecoveryController.cs: 38
LOW Log_Forging /src/Api/Platform/Push/Controllers/PushController.cs: 43
LOW Log_Forging /src/Api/Platform/Push/Controllers/PushController.cs: 43
LOW Log_Forging /src/Api/Controllers/DevicesController.cs: 191
LOW Log_Forging /src/Api/Controllers/DevicesController.cs: 191
LOW Log_Forging /src/Api/Controllers/DevicesController.cs: 97
LOW Log_Forging /src/Api/Controllers/DevicesController.cs: 97
LOW Log_Forging /src/Billing/Controllers/StripeController.cs: 164
LOW Log_Forging /src/Billing/Controllers/StripeController.cs: 164
LOW Log_Forging /src/Billing/Controllers/RecoveryController.cs: 38
LOW Log_Forging /src/Billing/Controllers/RecoveryController.cs: 38
LOW Log_Forging /src/Billing/Controllers/RecoveryController.cs: 38
LOW Log_Forging /src/Billing/Controllers/RecoveryController.cs: 38
LOW Log_Forging /src/Billing/Controllers/RecoveryController.cs: 38
LOW Log_Forging /src/Billing/Controllers/RecoveryController.cs: 38
LOW Log_Forging /src/Billing/Controllers/RecoveryController.cs: 38
LOW Log_Forging /src/Billing/Controllers/RecoveryController.cs: 38
LOW Log_Forging /src/Billing/Controllers/RecoveryController.cs: 38
LOW Log_Forging /src/Billing/Controllers/StripeController.cs: 164
LOW Log_Forging /src/Billing/Controllers/StripeController.cs: 164
LOW Log_Forging /src/Billing/Controllers/StripeController.cs: 164
LOW Log_Forging /src/Billing/Controllers/StripeController.cs: 164
LOW Log_Forging /src/Billing/Controllers/StripeController.cs: 164
LOW Log_Forging /src/Billing/Controllers/StripeController.cs: 164
LOW Log_Forging /src/Billing/Controllers/StripeController.cs: 164

@@ -66,6 +68,15 @@ public void ConfigureServices(IServiceCollection services)
services.Configure<IpRateLimitPolicies>(Configuration.GetSection("IpRateLimitPolicies"));
}

// TODO: Be more selective about adding this scaffolder
if (Environment.IsDevelopment())
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We likely want to be much more strict on when this runs. Some additional checks I am considering:

  1. Have this be behind a DEBUG compiler directive
  2. Only run this when ALL azure related connection strings are UseDevelopmentStorage=true.
  3. Only run this when ANY azure related connection strings are UseDevelopmentStorage=true.
  4. Run very selective scaffolding only for the things choosing UseDevelopmentStorage=true.
  5. #1 and #2
  6. #1 and #3

await ScaffoldAsync(cancellationToken);
}
// TODO: Handle certain errors with instructions on how to fix, like API version problems
catch (RequestFailedException requestedFailedEx) when (requestedFailedEx.ErrorCode == "InvalidHeaderValue")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically this error could be for a different header than the Api-Version header so I could also compare against the full exception message but I generally don't like that and have only ever seen this error because of that header.

_logger = logger;
}

public async Task StartAsync(CancellationToken cancellationToken)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any errors here, will stop the startup of the application. I could instead catch and not-rethrow errors to allow startup to continue but that will generally lead to the error showing up later in the application and likely not rethrowing a more descriptive error.

Copy link

codecov bot commented Feb 27, 2025

Codecov Report

Attention: Patch coverage is 4.12371% with 93 lines in your changes missing coverage. Please review.

Project coverage is 44.43%. Comparing base (dd78361) to head (6a8aec1).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...rc/Core/Platform/Infrastructure/AzureScaffolder.cs 0.00% 93 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5448      +/-   ##
==========================================
- Coverage   44.52%   44.43%   -0.09%     
==========================================
  Files        1514     1516       +2     
  Lines       70403    70660     +257     
  Branches     6352     6367      +15     
==========================================
+ Hits        31347    31398      +51     
- Misses      37708    37910     +202     
- Partials     1348     1352       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant